package com.caiyigo.baihua.serviceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.caiyigo.baihua.dao.KaoshicjMapper;
import com.caiyigo.baihua.dao.KaoshicjMapperSql;
import com.caiyigo.baihua.dao.KaoshikemuMapper;
import com.caiyigo.baihua.dao.KaoshikemuMapperSql;
import com.caiyigo.baihua.model.Kaoshikemu;
import com.caiyigo.baihua.model.Zhuanye;
import com.caiyigo.baihua.service.KaoshikemuService;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;

@Transactional
@Service
public class KaoshikemuServiceImpl implements KaoshikemuService {
	@Resource(name = "kaoshikemuMapper")
	KaoshikemuMapper kaoshikemuMapper;
	@Resource(name = "kaoshikemuMapperSql")
	KaoshikemuMapperSql kaoshikemuMapperSql;

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int deleteByPrimaryKey(String kmDm) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.deleteByPrimaryKey(kmDm);
	}

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int insert(Kaoshikemu record) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.insert(record);
	}

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int insertSelective(Kaoshikemu record) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.insertSelective(record);
	}

	@Override
	public Kaoshikemu selectByPrimaryKey(String kmDm) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.selectByPrimaryKey(kmDm);
	}

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int updateByPrimaryKeySelective(Kaoshikemu record) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.updateByPrimaryKeySelective(record);
	}

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int updateByPrimaryKey(Kaoshikemu record) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.updateByPrimaryKey(record);
	}

	@Override
	public List getList(Kaoshikemu dto, PageBounds pageBounds) {
		// TODO Auto-generated method stub
		return kaoshikemuMapperSql.getList(dto, pageBounds);
	}

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int batchDelete(String[] ids) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.batchDelete(ids);
	}

	@Override
	public Map<String, Kaoshikemu> getAll() {

		Map<String, Kaoshikemu> map = new HashMap<String, Kaoshikemu>();

		for (Kaoshikemu x : kaoshikemuMapper.getAll()) {
			map.put(x.getKmDm(), x);
		}
		return map;

	}

	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
	@Override
	public int batchUpdate(List<Kaoshikemu> record) {
		// TODO Auto-generated method stub
		return kaoshikemuMapper.batchUpdate(record);
	}

}
